package web.JavaDate;

import org.junit.jupiter.api.Test;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.10.10.57
 */
public class D2 {
    @Test
    public void m1(){
        final TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
        final TimeZone timeZone1 = TimeZone.getTimeZone("Asia/Hong_Kong");
        final TimeZone timeZone2 = TimeZone.getTimeZone("America/Mexico_City");
        Calendar c=Calendar.getInstance();
        SimpleDateFormat df1=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy年MM月dd日 hh:mm:ss");
        LocalDate d1=LocalDate.now();
        LocalDateTime d2=LocalDateTime.now();
        System.out.println(d1);
        System.out.println(d2);
        System.out.printf("中国时区");
        System.out.println(timeZone.getDisplayName()+" "+dtf.format(d2));
        c.setTimeZone(timeZone1);

        System.out.println(timeZone1.getDisplayName()+" "+String.format("%1$tF %1$tT",System.currentTimeMillis()));
        c.setTimeZone(timeZone2);
        c.setTime(new Date());
        System.out.println(timeZone2.getDisplayName()+" "+String.format("%1$tF %1$tT",c));
    }
}
